<template>
  <div>

    <el-dialog :visible.sync="formOpen" width="95%" custom-class="maxDialog actTaskDialog" :close-on-click-modal="false" :before-close="close" :lock-scroll="false">
      <ActTaskForm ref="actTaskForm" />
    </el-dialog>

    <el-dialog :visible.sync="processOpen" :title="$t('任务详情')" :close-on-click-modal="false" custom-class="dialogForm" :before-close="close">
      <ProcessInfoForm ref="processInfoForm" />
    </el-dialog>
  </div>
</template>

<script>

import { getTaskStatus } from '@/api/act/task/actTask'
import ActTaskForm from '@/views/act/task/actTaskForm'
import ProcessInfoForm from '@/views/act/process/processInfoForm'
export default {
  name: 'ProcessingTask',
  components: { ProcessInfoForm, ActTaskForm },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 待办页面是否展示
      formOpen: false,
      // 以后页面是否展示
      processOpen: false,
      // 总条数
      total: 0,
      // 待办表格数据
      todoList: [],
      // 弹出层标题
      title: '',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        title: undefined,
        applyUserId: '',
        processName: undefined
      },
      wfMenuProcessData: {},
      // 表单参数
      form: {}
    }
  },
  created() {
    if (this.$route.query.token) {
      this.getTaskStatus()
    }
  },
  mounted() {

  },
  methods: {
    close() {
      if (navigator.userAgent.indexOf('Firefox') !== -1 || navigator.userAgent.indexOf('Chrome') !== -1) {
        window.location.href = 'about:blank'
        window.close()
      } else {
        window.opener = null
        window.open('', '_self')
        window.close()
      }
    },
    getTaskStatus: function() {
      getTaskStatus(this.$route.query.taskId).then(response => {
        if (response.data === 'TODO') {
          this.formOpen = true
          this.$nextTick(() => {
            var data = { 'id': this.$route.query.taskId }
            this.$refs.actTaskForm.init(data)
          })
        } else {
          this.processOpen = true
          this.$nextTick(() => {
            var data = { 'actId': response.datas.actId }
            this.$refs.processInfoForm.init(data)
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
/deep/.actTaskDialog{
  .el-dialog__body{
    height: 100%;
    padding: 0px!important;
    .acttask, .row, .col{
      height: 100%;
    }
    .acttask{
      padding: 20px!important;
    }
  }
  .el-form-disabled{
    .el-row {
      .el-col{
        .el-form-item{
          &:after{
            width: 200px;
          }
          .el-form-item__label{
            width: 200px !important;
          }
        }
      }
    }
  }
}
</style>
